﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include "GnufButtonEx.h"
#include "GnufDropDownBoard.h"

namespace gnuf {

    // ToolButton class is the basic class of some kinds of complex buttons
    // that can have a dropdown board, like a dropdown menu or a combo box.

    class GNUF_BASE_EXPORT ToolButton : public ButtonEx
    {
    public:
        enum class PopupPolicy
        {
            eHover,
            eClick
        };
        virtual ~ToolButton();

    public:
        DropDownBoard* dropDownBoard() { return m_dropDownBoard.get(); }
        const DropDownBoard* dropDownBoard() const { return m_dropDownBoard.get(); }
        virtual void assignCustomizeArrowInfo(const Info&) override;
        const Info* customizeArrowInfo() const { return m_customizeArrowInfo.get(); }
        bool hasCustomizeArrow() const { return m_customizeArrowInfo.get() != nullptr; }
        virtual void onDropDownBoardItemClicked(Item*) {}
        void setRecordDropDownBoardUI(bool support);
        bool recordDropDownBoardUI() const;
        void setPopupPolicy(PopupPolicy policy);
        PopupPolicy popupPolicy() const { return m_popupPolicy; }

    protected:
        explicit ToolButton(Item*, EItemType, const char *);

    private:
        ToolButton(const ButtonEx&) = delete;
        ToolButton& operator=(const ButtonEx&) = delete;

    private:
        gcmp::OwnerPtr<DropDownBoard> m_dropDownBoard;
        gcmp::OwnerPtr<Info> m_customizeArrowInfo;
        PopupPolicy m_popupPolicy;
    };
}
